<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="renderer" content="webkit">
        <title>商户首页</title>
        <meta name="description" content="">
        <!-- <meta name="viewport" content="width=device-width, initial-scale=1,viewport-fit=cover"> -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />
        <meta content="telephone=no" name="format-detection" />
        <meta content="black" name="apple-mobile-web-app-status-bar-style" />	
		<!-- <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"> -->
        <!-- 引入样式 -->       
        <link rel="stylesheet" href="styles/common.css"/>
        <link rel="stylesheet" href="styles/global.css"/>
        <link rel="stylesheet" href="styles/index.css"/>
		<link rel="stylesheet" href="styles/font.css"/>
        <link rel="stylesheet" href="styles/vant.css">
        <!-- 引入组件 -->
		<script src="scripts/babel.js"></script>
        <script src="scripts/rem.js"></script>		
        <script src="scripts/vue.js"></script>
        <script src="scripts/vant.js"></script>
        <script src="scripts/api.js"></script>
        <script src="scripts/axios.js"></script>
		<!-- <script src="//cdn.jsdelivr.net/npm/eruda"></script>
		<script>eruda.init();</script> -->
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    
        <div class="container" id="app">
            <div class="header">
                <div></div>
                <div>商户</div>
                <div @click="jump_center" class="headericon"><span><i  class="iconfont icon-wo"></i></span></div> 
            </div>
            <div class="title">
                <div class="ftitle">今日收款</div>
                <div class="htitle" v-text="data.paymentamt+'元'"></div>
                <div class="hsum" v-text="'交易共'+data.count+'条'"></div>
            </div>
            <div class="detai_list container_list" >
                    <div class="list_tab">
                        <div @click="jump_coll_record">收款记录</div>
                        <div @click="jump_sta">收入统计</div>
                    </div>
                    <div class="list_title">
                   		 收款记录（今天最近十条）
                    </div>
					<div class="con_list">
						<div class="list" v-for="item in data.list">
						    <div >
						        <p v-text="item.username"></p>
						        <p v-text="item.paydate"></p>
						    </div>
						    <div v-text="item.paymentamt"></div>
						</div>
					</div>
                    
            </div>
        </div>
    </body>
	<script type="text/babel">		
		new Vue({
			el: '#app',
			data: {
				url:"",
				userId:"",
				token:"",
				admin:"",
				regId:"",
				data:{	
					paymentamt:'',
					count:'',
					list:[]
				}
			},
			mounted: function() {
				this.url = url();	
				var admin = localStorage.getItem("admin")?JSON.parse(localStorage.getItem("admin")):''	;
				if(admin=''||!admin){
					window.location.href='login.html';
					return
				}
				this.admin =JSON.parse(localStorage.getItem("admin"))
				this.userId = this.admin.mid;
				this.token = this.admin.token;
				this.selectMchMoney();
				
			},
			computed: {
			},
			methods: {
				// 商户今日收款展示 /mchapp/info/selectMchMoney
				selectMchMoney:function(){					
					var that =this;
					var data = {
						userId: that.userId,
						token: that.token,						
						requestString:JSON.stringify({
							mid: that.userId
						}) 
					}
					console.log(data)
					axios.post(that.url + '/mchapp/info/selectMchMoney', data)
					.then(function(response) {
						console.log(response.data);
						if (response.data.code == 200) {
							that.data = response.data;
							console.log(that.data)
						}
						//判断单点登录
						else if(response.data.code == 300){
							that.$notify("账号在别处登录，将为您返回登录页面");//							
							if(that.admin.teltype==1){
								logout_app(that.admin.mid,1)								
							}
							if(that.admin.teltype==2){
								logout_app(that.admin.mid,2)
							}	
							window.location.href ='login.html';
						} 
						else {
							localStorage.removeItem('admin');
							window.location.href = "login.html"
						}
					})
					.catch(function(error) {
						that.$notify("请求错误");
					});
				},
				jump_coll_record:function(){
					window.location.href = "views/collectionRecord.html"
				},
				jump_sta:function(){
					window.location.href = "views/statistics.html"
				},
				jump_center:function(){				
					window.location.href='views/personalCenter.html'
				},
				go_login: function() {
					window.location.href = 'login.html';
				},
				
			},
	
		})
	</script>
</html>